/*
 *    Copyright 2011 Kim Lindhardt Madsen
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package dk.lindhardt.gwt.geie.shared;

import java.io.Serializable;

/**
 * User: AnAmuser
 * Date: 10-07-11
 * <p/>
 * Images on the table.
 */
public class Image implements Serializable {

   private String base64Data;
   private double x;
   private double y;
   private double width;
   private double height;

   /**
    * Used for serialization
    */
   private Image() {
   }

   /**
    * A new Image. The data string can be created by by using gwt's Base64Utils like
    * <code>Base64Utils.toBase64(imageBytes)</code>
    * @param base64Data base 64 data.
    * @param x the x position in cells
    * @param y the y position in cells
    * @param width width in cells that the image spans
    * @param height height in the cells that the image spans
    */
   public Image(String base64Data, double x, double y, double width, double height) {
      this.base64Data = base64Data;
      this.x = x;
      this.y = y;
      this.width = width;
      this.height = height;
   }

   /**
    * Gets the data for the image as a string
    * @return the string containing the data
    */
   public String getBase64Data() {
      return base64Data;
   }

   /**
     * @return the image height in rows that the image spans
    */
   public double getHeight() {
      return height;
   }

   /**
    * @param height the image height in rows that the image spans
    */
   public void setHeight(double height) {
      this.height = height;
   }

   /**
    * @return image width in columns that the image spans
    */
   public double getWidth() {
      return width;
   }

   /**
    * @param width in columns that the image spans
    */
   public void setWidth(double width) {
      this.width = width;
   }

   /**
    * @return the x position in cells
    */
   public double getX() {
      return x;
   }

   /**
    * @param x the x position in cells
    */
   public void setX(double x) {
      this.x = x;
   }

   /**
    * @return the y position in cells
    */
   public double getY() {
      return y;
   }

   /**
    * @param y the y position in cells
    */
   public void setY(double y) {
      this.y = y;
   }

   /**
    * Copies this image
    * @return a new image
    */
   public Image copy() {
      return new Image(base64Data, x, y , width, height);
   }
}
